<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\controller;
use think\Loader;
use think\Cache;

class System extends CrmController
{
    /**
     * systemSet
     */
    public function systemSet()
    {
        $menuname = "System Set";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('systemSet');
    }


    /**
     * 加载系统参数数据
     * @return json 系统参数数据
     */
    public function systemSetData()
    {
        $arrData = Loader::model('System')->systemSetData();
        echo json_encode($arrData);
    }


    /**
     * 渲染模板addSystemSet
     */
    public function addSystemSet()
    {
        $menuname = "System Set";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('addSystemSet');
    }


    /**
     * 新增系统参数
     */
    public function insertSystemSet ()
    {
        $data = $_REQUEST;
        Loader::model('System')->insertSystemSet($data);
    }


    /**
     * 删除系统参数
     */
    public function delSystemSet ()
    {
        $id = $_REQUEST['id'];
        Loader::model('System')->delSystemSet($id);
    }


    /**
     * 渲染模板editSystemSet
     */
    public function editSystemSet()
    {
        $menuname = "System Set";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        $id = $_GET['id'];
        $data = Loader::model('System')->getSystemSet($id);
        $this->assign('data', $data);
        // 模板输出
        return $this->fetch('editSystemSet');
    }


    /**
     * 编辑系统参数
     */
    public function updateSystemSet ()
    {
        $data = $_REQUEST;
        Loader::model('System')->updateSystemSet($data);
    }



}